package com.wu.Backstage.util;

import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletResponse;
import java.sql.Date;
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.Calendar;


public class Utils {


    @Autowired
    private HttpServletResponse response;

    /**为方便后期使用，这里将获取时间和日期的方法分割来**/

    /**
     * 获取当前日期，格式yyyy-MM-dd
     * **/
    public static Date getDate()
    {
        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date(System.currentTimeMillis());
        return date;
    }
    /**
     * 获取当前日期，格式yyyy-MM-dd
     *
     * @return**/
//    public Date getDates()
//    {
//        Calendar calendar = Calendar.getInstance();
//        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
//        return date;
//    }

    /**
     * 获取当前时间，格式HH:mm:ss
     * **/
    public static Time getTime()
    {
        SimpleDateFormat formatter= new SimpleDateFormat("HH:mm:ss");

        Time time = new Time(System.currentTimeMillis());
        return time;
    }

    //随机验证码
    public String getcode(){
        String vcode = "";
        for (int i = 0; i < 6; i++) {
            vcode = vcode + (int)(Math.random() * 9);
        }
        return vcode;
    }


    public String[] setArray(String str)
    {
        String string = StrUtil.removeAll(str,'[',']','"');
        String s[] = string.split(",");
        return s;
    }


}
